load("//tools:defaults.bzl", "app_bundle", "http_server", "ts_library")
load("@npm//@angular/build-tooling/bazel/benchmark/component_benchmark:benchmark_test.bzl", "benchmark_test")
load("//modules/benchmarks:e2e_test.bzl", "e2e_test")

package(default_visibility = ["//modules/benchmarks:__subpackages__"])

ts_library(
    name = "incremental_dom",
    srcs = glob(["*.ts"]),
    tsconfig = "//modules/benchmarks:tsconfig-build.json",
    deps = [
        "//modules/benchmarks/src:util_lib",
        "//modules/benchmarks/src/largetable:util_lib",
    ],
)

app_bundle(
    name = "bundle",
    entry_point = ":index.ts",
    deps = [":incremental_dom"],
)

# The script needs to be called `app_bundle` for easier syncing into g3.
genrule(
    name = "app_bundle",
    srcs = [":bundle.debug.min.js"],
    outs = ["app_bundle.js"],
    cmd = "cp $< $@",
)

http_server(
    name = "devserver",
    srcs = [
        "index.html",
        "@npm//:node_modules/incremental-dom/dist/incremental-dom.js",
    ],
    deps = [":app_bundle"],
)

benchmark_test(
    name = "perf",
    server = ":devserver",
    deps = ["//modules/benchmarks/src/largetable:perf_tests_lib"],
)

e2e_test(
    name = "e2e",
    server = ":devserver",
    deps = ["//modules/benchmarks/src/largetable:e2e_tests_lib"],
)
